package com.zkc.bootnew.controller;


import com.zkc.bootnew.webservice.webuserservice;
import com.zkc.springbootnew.bean.Contact_user;
import com.zkc.springbootnew.utils.Dto;
import com.zkc.springbootnew.utils.DtoUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
@Controller
@RequestMapping("/enter")
@Api(tags = "第一次进入页面")
public class IndexController {


    @Resource
    webuserservice webuserservice;





    /*后台*/
    @GetMapping("/firstadmin")
    @ApiOperation(value = "进入后台借口")
    public String index(Model model) throws Exception {
        Integer id=35;
        Contact_user user=  webuserservice.usersingle(id);
        model.addAttribute("user",user);
        model.addAttribute("title","后台管理");
        return "FirstLevel/firstadmin";
    }


    /*后台默认显示页面*/
    @GetMapping("/controller")
    @ApiOperation(value = "进入后台默认显示页面")
    public String controller(Model model){
        return "FirstLevel/controller";
    }

    /*用户表*/
    @GetMapping("/usertable")
    @ApiOperation(value = "进入用户表页面")
    public String usertable(Model model){
        return "FirstLevel/usertable";
    }

    /*文章表*/
    @GetMapping("/connter")
    @ApiOperation(value = "进入文章表页面")
    public String connter(Model model){
        return "FirstLevel/connter";
    }

    /*分类表*/
    @GetMapping("/classification")
    @ApiOperation(value = "进入分类表页面")
    public String classification(Model model){
        return "FirstLevel/classification";
    }

    /*用户修改*/
    @GetMapping("/UserModification/{xid}")
    @ApiOperation(value = "进入用户修改页面")
    public String UserModification(@PathVariable("xid") Integer xid, Model model) throws Exception {
        Contact_user contactUser= webuserservice.usersingle(xid);
        model.addAttribute("id",contactUser.getId());       //id
        model.addAttribute("ContactAlias",contactUser.getContactalias());//用户名
        model.addAttribute("ContactName",contactUser.getContactname());//名字
        model.addAttribute("sex",contactUser.getSex());//性别
        model.addAttribute("QQ",contactUser.getQq());//qq
        model.addAttribute("WeChat",contactUser.getWechat());//wx号
        model.addAttribute("phone",contactUser.getPhone());//手机号
        model.addAttribute("ContactAvatar",contactUser.getContactavatar());//头像
        model.addAttribute("password",contactUser.getPassword());  //密码
        model.addAttribute("activation",contactUser.getActivation());//是否激活
        model.addAttribute("Permission",contactUser.getPermission());//是否有权限
        return "FirstLevel/UserModification";
    }



    /*进入用户添加页面*/
    @GetMapping("/UserAdd")
    @ApiOperation(value = "进入用户添加页面")
    public String UserAdd(Model model){
        return "FirstLevel/UserAdd";
    }









}
